package com.alpha.eceasy.mall.controller;

import com.alpha.eceasy.mall.api.dto.SendEmailDTO;
import com.alpha.eceasy.mall.service.impl.CommonServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/common")
@Slf4j
@Tag(description  = "公共操作接口", name = "公共操作接口")
public class CommonController {
    @Resource
    private CommonServiceImpl commonService;

    /**
     * 发送邮件
     */
    @Operation(description = "发送邮件", summary = "发送邮件")
    @PostMapping("/send")
    public Boolean sendEmail(@Valid @RequestBody SendEmailDTO sendEmailVO) {
        return commonService.sendEmail(sendEmailVO);
    }

    @Operation(description = "文件上传", summary = "文件上传")
    @PostMapping("/upload")
    public List<String> uploadImg(HttpServletRequest request, HttpServletResponse response) {
        return commonService.uploadImg(request, response);
    }
}
